using System;
using System.Collections.Generic;
using System.Text;

using Northwind.Domain.Entities;
using NUnit.Framework;

namespace Northwind.Domain.Tests.Custom
{
    [TestFixture]
    public class ProductFixture
    {
        [Test]
        public void VerifyNullableFields()
        {
            Product firstProduct = new Product();
            firstProduct.ProductName = "<sample-product>";
            firstProduct.Discontinued = false;
            firstProduct.Save();

            Product secondProduct = Product.Broker.GetByID(firstProduct.ProductID);

            Assert.AreEqual("<sample-product>", secondProduct.ProductName);

            Assert.IsNull(secondProduct.UnitPrice);
            Assert.IsFalse(secondProduct.UnitPrice.HasValue);

            Assert.IsNull(secondProduct.UnitsInStock);
            Assert.IsFalse(secondProduct.UnitsInStock.HasValue);

            Assert.IsNull(secondProduct.ReorderLevel);
            Assert.IsFalse(secondProduct.ReorderLevel.HasValue);

            secondProduct.Delete();

            Product thirdProduct = Product.Broker.GetByID(firstProduct.ProductID);

            Assert.IsNull(thirdProduct);
        }
    }
}
